package com.sh.data.engine.domain.datadev.flink.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sh.data.engine.common.util.FlinkUtil.FlinkCheckpointInfo;
import com.sh.data.engine.domain.base.model.PageResult;
import com.sh.data.engine.domain.datadev.flink.model.domain.*;
import com.sh.data.engine.domain.datadev.flink.model.param.SaveCollectionTaskParam;
import com.sh.data.engine.domain.datadev.flink.model.param.SaveFlinkTaskNodeParam;
import com.sh.data.engine.domain.datadev.flink.model.param.TaskRecordInfoParam;
import com.sh.data.engine.domain.shims.db.model.PreviewDataDomain;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Set;

/**
 * @author: zigui.zdf
 * @description:
 * @date: 2021/6/3 16:09
 */
public interface FlinkTaskV1Service {

    Boolean saveSqlTaskScript(SaveScriptDomain request, String userId, Long projectId);

    Boolean saveSource(SaveSourceDomain request, String userId, Long projectId);

    Boolean saveSink(SaveSinkDomain request, String userId, Long projectId);

    Boolean saveDim(SaveDimDomain request, String userId, Long projectId);

    Boolean saveEnv(SaveEnvDomain request, String userId, Long projectId);

    Boolean saveSchedule(SaveScheduleDomain request, String userId, Long projectId);

    FlinkTaskDetailDomain getTaskDetail(Long nodeId, Long versionId);

    String getSqlTaskScrpit(Long nodeId, Long versionId);

    List<FlinkSourceDomain> getSourceDetail(Long nodeId, Long versionId);

    List<FlinkSinkDomain> getSinkDetail(Long nodeId, Long versionId);

    List<FlinkDimDomain> getDimDetail(Long nodeId, Long versionId);

    String getEnvDetail(Long nodeId, Long versionId);

    FlinkScheduleDomain getScheduleDetail(Long nodeId, Long versionId);

    IPage<FlinkSqlTaskVersionDomain> getSqlTaskVersion(Long id, Integer pageNum, Integer pageSize);

    List<String> getDsType(Integer businessType);

    List<FlinkDatabaseDomain> getDatabasesByDsType(String dsType, Long projectId);

    FlinkTopicDomain getTopicAndColumns(Long dsId);

    Set<String> getTopics(Long dsId);

    List<FlinkTableDomain> getTables(Long dsId, Long projectId, String schema, Integer isPartition);

    List<FlinkTableFieldDomain> getTableFields(Long dsId, String tableName);

    List<String> getHbaseColumnFamilyNames(Long dsId, String tableName);

    Boolean rollbackVersion(Long nodeId, Long versionId);

    FlinkCheckGrammarDomain checkGrammar(String sql);

    Boolean saveFlinkCollectionTask(SaveCollectionTaskParam saveCollectionTaskParam);

    List<FlinkSourceTableInfoDomain> getSqlTaskSourceTables(Long nodeId);

    void downloadSqlTaskTemplate(Long nodeId, String tableName, HttpServletResponse response);

    List<List<String>> uploadDebugData(Long nodeId, String tableName, MultipartFile file);

    List<List<String>> collectOnlineData(Long nodeId, String tableName, Integer maxCount);

    FlinkDebugDomain startDebug(Long nodeId);

    Boolean stopDebug(Long jobId);

    FlinkJobLogDomain getLog(Long jobId);

    /*
     * flink运行记录接口
     * */
    PageResult<FlinkLogRecordDomain> getTaskRecordPageInfo(TaskRecordInfoParam taskRecordInfoParam);

    // FlinkSaveDataSyncResponse getFlinkSaveDataSyncResponseByNodeId(Long nodeId);

    FlinkLogDomain getTaskRecordDetailById(Long id);

    PreviewDataDomain previewData(Long dsId, String tableName);

    List<String> previewKafkaData(Long dsId, String topic);

    Boolean stopFlinkJob(Long id, Integer status);

    Boolean retryJob(Long id);

    Boolean restartJob(RestartJobDomain request);

    Boolean continueJob(Long id, String point);

    List<FlinkCheckpointInfo> getListCheckPoint(Long id);

    FlinkCheckpointInfo getLastSavepoint(Long id);

    List<String> getBinlogFileByDsId(Long dsId);

    List<String> getOracleSchemaByDsId(Long dsId);

    List<String> getTablesNames(List<String> tableName, Long projectId);

    List<HiveTableInfoDomain> getPartitionTableList(Long projectId);

    List<String> getPartitionInfoByTblName(String tableName, Long projectId);

    FlinkJobDetailDomain getFlinkRecordDetailByrecordId(Long recordId);

    FlinkTaskSummaryDomain getSummary(Long projectId);

    Boolean saveFlinkTaskNode(SaveFlinkTaskNodeParam param);

    Long getNodeIdForSp(String nodeName, Long projectId);
}
